﻿/*
 *	Copyright (c) 2009 Queensland University of Technology. All rights reserved.
 *	The QUT Bioinformatics Collection is open source software released under the 
 *	Microsoft Public License (Ms-PL): http://www.microsoft.com/opensource/licenses.mspx.
 */
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using QUT.Bio.Util;
using QUT.Bio.Graphs;
using QUT.Bio.SilverMap.ObjectModel;

namespace QUT.Bio.SilverMap.DefaultProvider {
	/// <summary>
	/// An Chromosome is a readonly wrapper for an object of the same name exposed by the Map web service.
	/// </summary>
	public class Chromosome: IComparable<Chromosome>, ISelectable {
		private string accession;
		private string description;
		private int geneCount;

		public Chromosome ( QUT.Bio.SilverMap.MapService.Organism organism )
			: this( organism.Accession, organism.Description, organism.GeneCount ) {
		}

		public Chromosome ( string accession, string description, int geneCount ) {
			this.accession = accession;
			this.description = description;
			this.geneCount = geneCount;
		}
		
		public override string ToString() {
			return string.Format( "{0} - {1}", Accession, Description );
			// return Description;
		}

		public string Accession {
			get {
				return accession;
			}
		}

		public string Description {
			get {
				return description;
			}
		}

		public int GeneCount {
			get {
				return geneCount;
			}
		}

		public int CompareTo( Chromosome c ) {
			return Description.CompareTo( c.Description );
		}

		public int CompareTo( object obj ) {
			return obj is Chromosome ? CompareTo( obj as Chromosome ) : -1;
		}

		public override bool Equals( object obj ) {
			return obj is Chromosome ? CompareTo( obj as Chromosome ) == 0 : false;
		}

		public override int GetHashCode() {
			return Description.GetHashCode();
		}

		public string SelectableText {
			get { 
				return Description;
			}
		}

		public int CompareTo ( ILinearDomain other ) {
			if ( other is Chromosome ) {
				return CompareTo( (Chromosome) other );
			}
			else {
				return -1;
			}
		}

		/// <summary>
		/// Satisfy the ISelectable contract, although I do not intend to use it in 
		/// this manner at present.
		/// </summary>

		public bool Selected {
			get;
			set;
		}

		#pragma warning disable 67
		public event PropertyChangedEventHandler  PropertyChanged;
		#pragma warning restore 67
	}
}
